<extend name="Public:common"/>

<block name="content">

    <div class="list-main layui-form">

		<div class="layui-tab">

            <ul class="layui-tab-title">

                <li class="layui-this"><eq name="Think.ACTION_NAME" value="agent">{:L('DEALER_LIST')}<else/>{:L('CUSTOMER_LIST')}</eq><span class="page-content">{:L('TOTAL_RECORDS')}：<span>{$pageCount|default='0'}</span> {:L('STRIP')}</span></li>

            </ul>

        </div>

		<!-- 筛选 -->
		<include file="Public/filterViewRange" />

		<volist name="filterlist" id="vo">

			<div class="list-filter select-fiter" data-type="highKeyword[define_form][{$vo.form_name}]">

				<div class="list-filter-tit">{$vo.form_description}</div>

				<volist name="vo.option" id="v">

					<div class="list-filter-checkbox <if condition="in_array($v,explode(',',$highKeyword['define_form'][$vo['form_name']]))">active</if>" data-value="{$v}"><span class="iconfont <if condition="in_array($v,explode(',',$highKeyword['define_form'][$vo['form_name']]))">icon-square-selected<else/>icon-weixuanzhong</if>"></span>{$v}</div>

				</volist>

			</div>

		</volist>

		<div class="list-filter" data-type="highKeyword[time_range_type]">

			<div class="list-filter-tit">{:L('SELECT_TIME')}</div>

			<include file="Public/searchTimeRange" />

			<div data-value="create_time" class="filter-time-type layui-form-radio mt0 <eq name='highKeyword[time_range_type]' value='create_time'>layui-form-radioed</eq><empty name='highKeyword[time_range_type]'>layui-form-radioed</empty> ml15 fts13 gray6">
				<i class="iconfont <eq name='highKeyword[time_range_type]' value='create_time'>icon-xuanzhong<else/><empty name='highKeyword[time_range_type]'>icon-xuanzhong<else/>icon-xuanze</empty></eq> fts15"></i>
				<div>{:L('CREATE_TIME')}</div>
			</div>

			<div data-value="next_contact_time" class="filter-time-type <eq name='highKeyword[time_range_type]' value='next_contact_time'>layui-form-radioed</eq> layui-form-radio mt0 fts13 gray6">
				<i class="iconfont <eq name='highKeyword[time_range_type]' value='next_contact_time'>icon-xuanzhong<else/>icon-xuanze</eq> fts15"></i>
				<div>{:L('NEXT_CONTACT')}</div>
			</div>

			<div data-value="last_follow_time" class="filter-time-type <eq name='highKeyword[time_range_type]' value='last_follow_time'>layui-form-radioed</eq> layui-form-radio mt0 fts13 gray6">
				<i class="iconfont <eq name='highKeyword[time_range_type]' value='last_follow_time'>icon-xuanzhong<else/>icon-xuanze</eq> fts15"></i>
				<div>{:L('FINAL_FOLLOW-UP')}</div>
			</div>

		</div>

		<include file="Public/filterSortBy" />

        <div class="list-header clearfix">

            <div class="header-left">

                {:FEELCRM('Customer/create','',L('ADD_CUSTOMER'),'item-deleteBtn','','iconfont icon-adduser')}

            </div>

            <div class="header-right">

				<div class="customer-listOperate">

					<div class="listOperate">

						<div class="layui-form">

							<select class="layui-input" disabled><option>{:L('OPERATION')}</option></select>

						</div>

						<div class="operate hidden">

							<notempty name="istoPoolCustomerAuth">

								<a href="javascript:"  data-href="{:U('Customer/toPool')}" data-name="{:L('GIVE_UP_CUSTOMERS')}" id="toPoolCustomer">{:L('GIVE_UP_CUSTOMERS')}</a>

							</notempty>

							<notempty name="istransferCustomerAuth">

								<a href="javascript:" class="chooseMemberDetail" data-id="" data-href="{:U('Customer/transfer')}" data-name="{:L('TRANSFER')}" id="transferCustomer">{:L('CUSTOMER_TRANSFER')}</a>

							</notempty>

							<eq name="isTicketAuth" value="10">

							<notempty name="iscreateFeeldeskAuth">

								<a href="javascript:"  data-href="{:U('Customer/createFeeldesk')}" title="{:L('USE_LOGIN_TICKET')}" data-name="{:L('ADD_TO_MEMBER')}" id="createFeeldesk">{:L('ADD_TO_MEMBER')}</a>

							</notempty>

							</eq>

							<notempty name="isDelCustomerAuth">

								<a href="javascript:"  data-href="{:U('Customer/delete')}" data-name="{:L('DELETE')}" id="delCustomer">{:L('DELETE_CUSTOMER')}</a>

							</notempty>

							<notempty name="isExportCustomerAuth">

								<a href="javascript:" title="{:L('EXPORT')}" id="startExport">{:L('EXPORT_DATA')}</a>

							</notempty>

							<notempty name="isImportCustomerAuth">

								<a href="javascript:" id="uploadFile">{:L('IMPORT_CUSTOMER')}</a>

								<a href="__ROOT__/{$importTemp}" title="{:L('CUSTOMER_IMPORT_TEMPLATE')}" download="{:L('CUSTOMER_IMPORT_TEMPLATE')}" >{:L('DOWNLOAD_TEMPLATE')}</a>

							</notempty>

						</div>

					</div>

				</div>

				<span class="advanced-searc-btn fr" id="advanced-search-btn"><i class="iconfont icon-shaixuan"></i> <span>{:L('ADVANCED_SEARCH')}</span></span>

                <form action="{$controllerAndAction}" method="get" class="fr" id="filterForm">

					<input type="hidden" name='customer_auth' value="{$customer_auth}" />

					<input type="hidden" name='sort_by' value="{$sort_by}" />

					<input type="hidden" name='highKeyword[condition]' value="1" />

					<input type="hidden" name='highKeyword[define_form][importance]' value="{$highKeyword.define_form.importance}" />

					<input type="hidden" name='highKeyword[define_form][customer_grade]' value="{$highKeyword.define_form.customer_grade}" />

					<input type="hidden" name="highKeyword[start_time]"  value="{$highKeyword.start_time}" />

					<input type="hidden" name="highKeyword[end_time]"  value="{$highKeyword.end_time}" />

					<input type="hidden" name="highKeyword[time_range_type]" value="{$highKeyword.time_range_type}" />

					<!--<include file="Public/searchTimeRange" />-->

					<div class="compact-menu">

						<!--<notempty name="isExportCustomerAuth">

							<a href="javascript:" title="{:L('EXPORT')}" id="startExport"><i class="iconfont icon-download"></i></a>

						</notempty>

						<a href="javascript:" title="{:L('ADVANCED_SEARCH')}" id="advanced-search-btn"><i class="iconfont icon-shaixuan"></i></a>-->

					</div>

                    <div class="compact-search">

                        <i class="iconfont icon-search crmSearchBtn"></i>

                        <input type="text" name="keyword" value="{$keyword}" placeholder="{:L('CLIENT_NAME')}/{:L('CONTACT')}/{:L('PHONE')}/{:L('MAILBOX')}/{:L('WECHAT_NUMBER')}" onkeydown="javascript:if (event.keyCode == 13){$(this).parents('form').submit();}" />

                        <!--<a href="javascript:" class="searchBtn">{:L('SEARCH')}</a>-->

                    </div>

                </form>

            </div>

        </div>

		<div id="advanced-search" class="hidden feelcrm-advanced-search feeldesk-form hg100">

			<form action="{$controllerAndAction}" method="get" id="highSearchForm" class="hg100">

				<input type="hidden" name='customer_auth' value="{$customer_auth}" />

				<input type="hidden" name='sort_by' value="{$sort_by}" />

				<notempty name="source_type" >

					<input type="hidden" name="source_type" value="{$source_type}">

					<notempty name="encryData">

						<input type="hidden" name="apiData" value="{$encryData}">

					</notempty>

				</notempty>

			<include file="Public/highKeywordHeader" />

					<!--<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('CUSTOMER_RESPONSIBLE')}

						</label>

						<div class="layui-input-inline">

							<select name="highKeyword[member_id]" lay-ignore id="kwMemberId">

								<option value="">{:L('CHOOSE')}{:L('CUSTOMER_RESPONSIBLE')}</option>

								<volist name="members" id="v">

									<option value="{$v.member_id}" <eq name="highKeyword.member_id" value="$v.member_id">selected</eq>>{$v.name}</option>

								</volist>

							</select>

							<script>

								$("#kwMemberId").select2();

							</script>

						</div>

						<i class="layui-icon layui-icon-about intro-icon" data-note="{:L('ENTER_NAME_SEARCH')}"></i>

					</div>-->

					<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('CUSTOMER_NUMBER')}

						</label>

						<div class="layui-input-inline">

							 <input type="text" name="highKeyword[customer_no]" value="{$highKeyword.customer_no}" placeholder="" class="layui-input">

						</div>

						<i class="layui-icon layui-icon-about intro-icon" data-note="{:L('SEARCH_FUZZY_QUERY')}"></i>

					</div>

					<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('TRANSACTION_STATUS')}

						</label>

						<div class="layui-input-inline">

							<input type="radio" name="highKeyword[is_trade]" value="0" <eq name="highKeyword.is_trade" value="0">checked</eq> title="{:L('UNSOLD')}">

							<input type="radio" name="highKeyword[is_trade]" value="1" <eq name="highKeyword.is_trade" value="1">checked</eq> title="{:L('DEAL_DONE')}">

						</div>

					</div>

					<include file="Public/highKeywordForm" />

					<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('CONTACT_NAME')}

						</label>

						<div class="layui-input-inline">

							 <input type="text" name="highKeyword[contacter_name]" value="{$highKeyword.contacter_name}" placeholder="" class="layui-input">

						</div>

						<i class="layui-icon layui-icon-about intro-icon" data-note="{:L('SEARCH_FUZZY_QUERY1')}"></i>

					</div>

					<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('CONTACT_NUMBER')}

						</label>

						<div class="layui-input-inline">

							 <input type="text" name="highKeyword[contacter_phone]" value="{$highKeyword.contacter_phone}" placeholder="" class="layui-input">

						</div>

						<i class="layui-icon layui-icon-about intro-icon" data-note="{:L('SEARCH_FUZZY_QUERY1')}"></i>

					</div>

					<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('CONTACT_EMAIL')}

						</label>

						<div class="layui-input-inline">

							 <input type="text" name="highKeyword[contacter_email]" value="{$highKeyword.contacter_email}" placeholder="" class="layui-input">

						</div>

						<i class="layui-icon layui-icon-about intro-icon" data-note="{:L('SEARCH_FUZZY_QUERY1')}"></i>

					</div>

				</div>

			</div>

			</form>

		</div>

        <div id='list' class="item-list feelcrm-list" >

            <table class="layui-table" lay-skin="line">

                <thead>

                    <tr>

						<th class="checkbox"><input type="checkbox" name="" lay-skin="primary" lay-filter="ListAllChoose"></th>

						<!--<th>{:L('CUSTOMER_NUMBER')}</th>

                        <th>{:L('INFORMATION_COMPLETENESS')}</th>-->

						<volist name="formList" id="vo">

							<!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
							<if condition="!$vo['role_id'] || in_array($index['role_id'],explode(',',$vo['role_id']))">
							<th>{$vo.form_description}</th>

							<eq name="vo.form_name" value="name">

								<th>{:L('INFORMATION_COMPLETENESS')}</th>

							</eq>
							</if>

						</volist>

						<!--<th>{:L('CUSTOMER_CONTACT')}</th>

						<th>{:L('TEL')}</th>-->

						<th>{:L('FINAL_FOLLOW-UP')}</th>

						<th>{:L('NEXT_CONTACT')}</th>

						<!--<th>{:L('IS_LOSE_ORDER')}</th>-->

						<th>{:L('CREATE_TIME')}</th>

						<th>{:L('LEADER')}</th>

						<th>{:L('FOUNDER')}</th>

						<th>{:L('ENTRY_METHOD')}</th>

                    </tr>

                </thead>

                <tbody>

                    <empty name="customer">

                        <tr class="nodata center">

                            <td colspan="11">

                                <p><i class="iconfont icon-nothing fts20"></i></p>

                                <p>{:L('NO_DATA')}</p>

                            </td>

                        </tr>

                    <else />

                        <volist name="customer" id="vo">

                            <tr data-id="{$vo.customer_id|encrypt='CUSTOMER'}" data-no="{$vo.customer_prefix}{$vo.customer_no}">

								<td class="checkbox relative">

									<input type="checkbox" name="del[]" lay-skin="primary" value="{$vo.customer_id|encrypt='CUSTOMER'}" >

								</td>

								<!--<td mini='customer'>{$vo.customer_prefix}{$vo.customer_no}</td>

                                 <td mini='customer'>{$vo.percent}</td>-->

								<volist name="formList" id="v">

									<!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
									<if condition="!$v['role_id'] || in_array($index['role_id'],explode(',',$v['role_id']))">
									<td mini='customer' <eq name="v.form_type" value="textarea">title="{$vo['detail'][$v['form_name']]|strip_tags}"</eq> <eq name='v.form_name' value='name'>class="blue8"</eq> >

										<eq name="v.form_type" value="textarea">
											{:mb_substr(strip_tags($vo['detail'][$v['form_name']]),0,20)}...
										<else/>

											{$vo['detail'][$v['form_name']]|default='--'}

											<eq name="v.form_name" value="phone">

												<notempty name="vo['detail'][$v['form_name']]">
													<span class="icon-onclickcall"><i class="iconfont icon-boda blue8" onclick="CallUp({$vo['detail'][$v['form_name']]},3);"></i></span>
												</notempty>

											</eq>

										</eq>

									</td>

									<eq name="v.form_name" value="name">

										<td mini='customer'>{$vo.percent}</td>

									</eq>

									</if>
								</volist>

                                <!--<td mini='customer'>{$vo.contacter_name}</td>

                                <td mini='customer'>{$vo.contacter_phone}</td>-->

                                <td mini='customer'>{$vo.lastfollowtime|getDates}</td>

                                <td mini='customer'>{$vo.nextcontacttime|getDates}</td>

								<td mini='customer'>{$vo.createtime|getDates}</td>

                                <!--<td mini='customer'><eq name='vo.is_losed' value='1'><span class="red1">{:L('YES')}</span><else/><span class="blue1">{:L('NO')}</span></eq></td>-->

                                <td mini='customer'>{$vo.member_name}</td>

                                <td mini='customer'>{:getCustomerCreateName($vo['creater_id'],$vo['create_name'])}</td>

                                <td mini='customer'>{:getCrmEntryMethod($vo['entry_method'])}</td>

                                <!--<td class="listOperate hidden">

                                    <i class="iconfont icon-dian"></i>

                                    <div class="operate hidden">

                                        {:FEELCRM('Customer/edit',['id'=>encrypt($vo['customer_id'],'CUSTOMER'),'type'=>encrypt('index','CUSTOMER')],L('EDITOR'))}

                                        {:FEELCRM('Customer/delete',['id'=>encrypt($vo['customer_id'],'CUSTOMER'),'type'=>encrypt('index','CUSTOMER')],L('DELETE'),'','async')}

                                    </div>

                                </td>-->

                            </tr>

                        </volist>

                    </empty>

                </tbody>

            </table>

            <div class="right-list-page clearfix"><div class="feeldesk-page">{$page}</div></div>

        </div>

		<notempty name="istransferCustomerAuth">

			<include file="Public/selectMember" />

		</notempty>

		<notempty name="istoPoolCustomerAuth">

			<include file="Public/toPool" />

		</notempty>


		<script>

			$(function(){

				$('#Memberlist .feeldesk-page a').click(function(){

					pageclick(this,'/Customer/index');

					return false;
				})

			})

		</script>

		<script type="text/javascript">

			layui.use('upload', function()
			{
				var upload = layui.upload;

				upload.render(
				{
					elem:'#uploadFile',

					url: "{:U('Upload/importExcel',['source'=>'customer'])}",

					field:'excel',

					exts: 'xlsx|xls',

					accept:'file',

					before:function()
					{
						layer.msg("{:L('IMPORT_LOADING')}",{time:1000000,shift:0,offset:['100px']})
					},
					done: function(res)
					{
						if(res.error == 1)
						{
							layer.msg(res.msg,{icon:1,time:1000,shift:0,offset:['60px']},function()
							{
								window.location.href = res.url;
							});
						}
						else
						{
							layer.msg(res.msg,{icon:2,time:2000,offset:['60px']});
						}
					}
				})
			});

			layui.use('form',function()
			{
				var form = layui.form;

				form.render('checkbox');

				form.render('radio');

				form.render('select');

			})

		</script>

    </div>

	<include file="Public/exportpage" />

	<script>

		var export_url = "/Customer/export";

		var export_action = "{$Think.ACTION_NAME}";

	</script>

</block>
